﻿@using DCMS.ViewModel.Models.Finances;
@model CostContractBillModel

@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(m => m.CustomerId)
@Html.HiddenFor(m => m.AccountingOptionId)
@Html.HiddenFor(m => m.AccountCodeTypeId)
@Html.HiddenFor(m => m.LeaderId)

<input asp-for="BillTypeEnumId" type="hidden" />


@if (!ViewData.ModelState.IsValid)
{
    <div class="alert alert-warning alert-dismissable mt10 mb10">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <div asp-validation-summary="All"></div>
    </div>
}


<form class="form-horizontal" role="form">
    <div class="form-group">
        <div class="col-md-2 pt10">
            <label class="checkbox-inline mr10">
                <input type="checkbox" id="costCheckType1" value="0" checked="checked" @(Model.AuditedStatus ? "disabled" : "")><span class="text-primary">按月兑付</span>
            </label>
            <label class="checkbox-inline mr10 hide" id="costCheckType2_box">
                <input type="checkbox" id="costCheckType2" value="2" @(Model.AuditedStatus ? "disabled" : "")> <span class="text-primary">从主管赠品扣减</span>
            </label>
        </div>
        <div class="col-md-2 hide" id="costLeader_box">
            <dcms-input asp-for="LeaderName" class="form-control" placeholder="主管..." asp-readonly="true" />
            @*<dcms-select asp-for="LeaderId" asp-items="@Model.Leaders" asp-default="主管" asp-disabled="@Model.AuditedStatus" />*@
        </div>
    </div>
</form>

<div class="row">
    <div class="col-sm-2">
        <div class="input-group">
            <dcms-input asp-for="CustomerName" class="form-control" placeholder="客户..." asp-readonly="@Model.AuditedStatus" />
            <span class="input-group-btn">
                <button id="btn_search_customer" type="button" class="btn btn-default" @(Model.AuditedStatus ? "disabled" : "")>
                    <span class="glyphicon glyphicon-search"></span>
                </button>
            </span>
        </div>
    </div>
    <div class="col-sm-2">
        <dcms-select asp-for="EmployeeId" asp-items="@Model.Employees" asp-default="员工" asp-disabled="@Model.AuditedStatus" />
    </div>

    <div class="col-sm-2">
        <div class="input-group">
            <dcms-input asp-for="AccountingOptionName" class="form-control" placeholder="费用类别..." asp-readonly="@Model.AuditedStatus" />
            <span class="input-group-btn">
                <button id="btn_search_options" type="button" class="btn btn-default" @(Model.AuditedStatus ? "disabled" : "")>
                    <span class="glyphicon glyphicon-search"></span>
                </button>
            </span>
        </div>
    </div>
    <div class="col-sm-2" id="costYear_box">
        <select class="form-control" id="Year" name="Year" @(Model.AuditedStatus ? "disabled" : "")>
            <option value="0">选择年份</option>
            @{
                int j = 0;
                List<int> Years = new List<int>();
                for (var i = 0; i < 20; i++)
                {
                    if (i < 10)
                    {
                        Years.Add(DateTime.Now.AddYears(-i).Year);
                    }
                    else
                    {
                        j++;
                        Years.Add(DateTime.Now.AddYears(j).Year);
                    }
                }
                foreach (var year in Years.OrderBy(y => y))
                {
                    @*<option value="@(year)" selected="@(Model.Year==year ? "selected" : "" )">@(year)</option>*@
                    @if (Model.Year > year)
                    {
                        <option value="@(year)" disabled style="color:grey;">@(year)</option>
                    }
                    else if (Model.Year == year)
                    {
                        <option value="@(year)" selected="selected">@(year)</option>
                    }
                    else
                    {
                        <option value="@(year)">@(year)</option>
                    }
                }
            }
        </select>
    </div>
    <div class="col-sm-2 hide" id="costMonth_box">
        <select class="form-control" id="Month" name="Month" @(Model.AuditedStatus ? "disabled" : "")>
            <option value="0">选择月份</option>
            @{
                int k = 0;
                List<DateTime> Months = new List<DateTime>();
                var start = DateTime.Now.AddMonths(-DateTime.Now.Month);
                for (var i = 1; i <= 12; i++)
                {
                    k++;
                    Months.Add(start.AddMonths(i));
                }
                foreach (var m in Months.OrderBy(y => y))
                {
                    @*<option value="@(m.Month)" selected="@(Model.Month==m.Month ? "selected" : "" )">@(m.ToString("yyyy-MM"))</option>*@

                    @if (Model.Month > m.Month)
                    {
                        <option value="@(m.Month)" disabled style="color:grey;">@(m.ToString("yyyy-MM"))</option>
                    }
                    else if (Model.Month == m.Month)
                    {
                        <option value="@(m.Month)" selected="selected">@(m.ToString("yyyy-MM"))</option>
                    }
                    else
                    {
                        <option value="@(m.Month)">@(m.ToString("yyyy-MM"))</option>
                    }
                }
            }
        </select>
    </div>
    @*<div class="col-sm-2">
            <dcms-editor asp-for="StartTime" placeholder="开始..." />
        </div>
        <div class="col-sm-2">
            <dcms-editor asp-for="EndTime" placeholder="结束..." />
        </div>*@
    <div class="col-sm-2">
        <dcms-input asp-for="ProtocolNum" class="form-control" placeholder="TPM协议编码..." asp-readonly="@Model.ProtocolNum" />
    </div>
</div>
<br />
<div class="row">
    
    <div class="col-sm-2">
        <dcms-input asp-for="Remark" class="form-control" placeholder="备注..." asp-readonly="@Model.AuditedStatus" />
    </div>
    <div class="col-sm-2">
        <dcms-input asp-for="SaleRemark" class="form-control" placeholder="销售备注..." asp-readonly="@Model.AuditedStatus" />
    </div>
</div>

     @if (Model.Id != 0 && !string.IsNullOrEmpty(@Model.BillBarCode)) { <div class="row mtn mb10 mt10">
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">单据编号：</lable>
                <div class="col-lg-9">
                    <input asp-for="BillNumber" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">制单：</lable>
                <div class="col-lg-9">
                    <input asp-for="MakeUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">审核：</lable>
                <div class="col-lg-9">
                    <input asp-for="AuditedUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <img class="media-object mn thumbnail pull-right" src="@Model.BillBarCode" />
        </div>
    </div>
}


<div class="row mt10 mb10">
    <div class="col-md-12">
        <table id="CostContractItems" class="table table-striped table-bordered table-hover"></table>
    </div>
</div>


